package org.exia.minisig.application;

import java.io.BufferedWriter;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Calendar;

import javax.swing.filechooser.FileSystemView;

public class LogFile {
	private LogFile(){
	}
	
	public static void setEntry(String content){
		FileSystemView fsv = FileSystemView.getFileSystemView();
		File f = fsv.getDefaultDirectory(); 
		try {			 
			File file = new File(f + "\\miniSIG\\miniSIG.log");
			if (!file.exists()) {
				file.createNewFile();
			}
			FileWriter fw = new FileWriter(file.getAbsoluteFile());
			BufferedWriter bw = new BufferedWriter(fw);
			bw.write(content);
			bw.newLine();
			
			Calendar currentDate = Calendar.getInstance();
			SimpleDateFormat formatter= new SimpleDateFormat("yyyy/MMM/dd HH:mm:ss"); //format it as per your requirement
			String dateNow = formatter.format(currentDate.getTime());
			bw.write("---------------------" + dateNow +  "--------------------------");
			
			bw.close();
		} catch (FileNotFoundException | UnsupportedEncodingException e1) {
		} catch (IOException e) {
		}
	}
	
	
}
